package org.tity.test.entity.raw.sys;

import org.tity.sql.entity.EntitySet;
import org.tity.sql.data.Rcd;
import org.tity.sql.entity.Entity;
import java.lang.Boolean;
import javax.persistence.Table;
import org.tity.sql.entity.annotations.TableDesc;
import javax.persistence.Id;
import org.tity.sql.entity.annotations.IdGenerator;
import javax.persistence.Column;
import org.tity.sql.meta.DBTypeCategery;
import org.tity.sql.entity.annotations.ColumnDesc;
import org.tity.sql.dao.DAO;
import org.tity.test.entity.raw.hr.PersonSet;
import org.tity.test.entity.raw.hr.Person;
import org.tity.test.entity.raw.sys.DictItemSet;
import org.tity.test.entity.raw.sys.DictItem;
import org.tity.test.entity.raw.sys.RoleSet;
import org.tity.test.entity.raw.sys.Role;


/*
 * 此类代码为自动生成，请勿修改 !
 */

/**
 * 
 * @author tity-code-builder-powered-by-lifangjie
 * @date 2019-02-13 09:57:00
 **/
@javax.persistence.Entity
@Table(name="sys_user")
@TableDesc("")
public class User extends Entity {
	/**
	 * 用于按照当前实体指定参数集
	*/
	public static final String PARAM_NAMES="[$:allfields:org.tity.test.entity.raw.sys.User:&]";
	/**
	 * 用于按照当前实体主键指定参数集
	*/
	public static final String PARAM_PK_NAMES="[$:pkfields:org.tity.test.entity.raw.sys.User:&]";

	/**
	 * 构造函数(从数据库构建)
	*/
	public User(EntitySet ownerSet,Rcd rcd) {
		super(ownerSet,rcd);
		super.logicValues=new Object[]{"Y","N"};
	}

	/**
	 * 构造函数(直接构建)
	*/
	public User() {
		super(null,null);
		super.logicValues=new Object[]{"Y","N"};
	}

	/**
	 * 获取字段 id 的值<br/>
	 */
	@Id
	@IdGenerator(type=IdGenerator.SNOWFLAKE)
	@Column(name="id",nullable=false)
	@ColumnDesc(label="id",comment="id",internal=false,type=DBTypeCategery.biginteger)
	public Long getId() {
		return this.getValue("id",Long.class);
	}

	/**
	 * 设置字段 id 的值<br/>
	 */
	public User setId(Long value) {
		super.setValue("id",value);
		return this;
	}

	/**
	 * 获取字段 account 的值<br/>
	 */
	@Column(name="account",nullable=true,length=64)
	@ColumnDesc(label="account",comment="account",internal=false,type=DBTypeCategery.string)
	public String getAccount() {
		return this.getValue("account",String.class);
	}

	/**
	 * 设置字段 account 的值<br/>
	 */
	public User setAccount(String value) {
		super.setValue("account",value);
		return this;
	}

	/**
	 * 获取字段 password 的值<br/>
	 */
	@Column(name="password",nullable=true,length=32)
	@ColumnDesc(label="password",comment="password",internal=false,type=DBTypeCategery.string)
	public String getPassword() {
		return this.getValue("password",String.class);
	}

	/**
	 * 设置字段 password 的值<br/>
	 */
	public User setPassword(String value) {
		super.setValue("password",value);
		return this;
	}

	/**
	 * 获取字段 area_type 的值<br/>
	 */
	@Column(name="area_type",nullable=true,length=4)
	@ColumnDesc(label="area_type",comment="area_type",internal=false,type=DBTypeCategery.string)
	public String getAreaType() {
		return this.getValue("area_type",String.class);
	}

	/**
	 * 设置字段 area_type 的值<br/>
	 */
	public User setAreaType(String value) {
		super.setValue("area_type",value);
		return this;
	}

	/**
	 * 获取字段 card_type 的值<br/>
	 */
	@Column(name="card_type",nullable=true,length=4)
	@ColumnDesc(label="card_type",comment="card_type",internal=false,type=DBTypeCategery.string)
	public String getCardType() {
		return this.getValue("card_type",String.class);
	}

	/**
	 * 设置字段 card_type 的值<br/>
	 */
	public User setCardType(String value) {
		super.setValue("card_type",value);
		return this;
	}

	/**
	 * 获取字段 deleted 的值<br/>
	 */
	@Column(name="deleted",nullable=true,length=1)
	@ColumnDesc(label="deleted",comment="deleted",internal=true,type=DBTypeCategery.bool)
	public Boolean isDeleted() {
		return this.getValue("deleted",Boolean.class);
	}

	/**
	 * 设置字段 deleted 的值<br/>
	 */
	public User setDeleted(Boolean value) {
		super.setValue("deleted",value);
		return this;
	}

	/**
	 * 生成并设置ID值
	*/
	@Override 
	public User generateId() {
		super.generateIdInternal(null);
		return this;
	}

	/**
	 * 通过指定的DAO，生成并设置ID值
	*/
	@Override 
	public User generateId(DAO dao) {
		super.generateIdInternal(dao);
		return this;
	}

	public Person getPerson() {
		return (Person)this.getOneToOneRef("join-person-on(local.id=entity.id)");
	}

	public DictItem getAreaTypeDictItem() {
		return (DictItem)this.getOneToOneRef("join-dictitem-on(local.area_type=entity.id)");
	}

	public DictItem getCardTypeDictItem() {
		return (DictItem)this.getOneToOneRef("join-dictitem-on(local.card_type=entity.id)");
	}

	public RoleSet getRoleSet() {
		return (RoleSet)this.getOneToManyRef("join-role-on(entity.id=rel.role_id and local.id=rel.user_id)");
	}

}
